// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import { ccs } from "../../script/util/services";
import { WinBase } from "../../script/wins/WinBase";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends WinBase {

    @property(cc.Component.EventHandler)
    _closeFunc: Function = null;

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {}

    start () {

    }   
    closeWin() {
        let closeFunc = () => {
            if(!cc.isValid(this.node.parent)) return;
            if(this.node.parent.active && this._isClickClose){
                this.node.parent.getComponent(WinBase)._close();
            }
        };
        this.touchEndEventScale(this.node, (event: cc.Event.EventTouch)=>{
            ccs.gf.doCallback(this._closeFunc, this, event);
            if(!this._isTouchBeginClose) {
                closeFunc();
            }
        },this, closeFunc);
    }
}
